<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Index of iterators of a map storing variant geometries</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Geometry">
<link rel="up" href="../rtree_examples.html" title="Examples">
<link rel="prev" href="index_of_shared_pointers_to_polygons.html" title="Index of shared pointers to polygons">
<link rel="next" href="specializing_index__indexable_function_object___storing_shared_pointers_in_the_rtree.html" title="Specializing index::indexable function object - storing shared pointers in the rtree">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="index_of_shared_pointers_to_polygons.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rtree_examples.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="specializing_index__indexable_function_object___storing_shared_pointers_in_the_rtree.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="geometry.spatial_indexes.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries"></a><a class="link" href="index_of_iterators_of_a_map_storing_variant_geometries.html" title="Index of iterators of a map storing variant geometries">Index
        of iterators of a map storing variant geometries</a>
</h4></div></div></div>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">box</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">ring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">index</span><span class="special">/</span><span class="identifier">rtree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">cmath</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">map</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">foreach</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">variant</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span>
<span class="keyword">namespace</span> <span class="identifier">bgi</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">index</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">&gt;</span> <span class="identifier">point</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">box</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;</span> <span class="identifier">box</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span> <span class="keyword">false</span><span class="special">,</span> <span class="keyword">false</span><span class="special">&gt;</span> <span class="identifier">polygon</span><span class="special">;</span> <span class="comment">// ccw, open polygon</span>
<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">ring</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">,</span> <span class="keyword">false</span><span class="special">,</span> <span class="keyword">false</span><span class="special">&gt;</span> <span class="identifier">ring</span><span class="special">;</span> <span class="comment">// ccw, open ring</span>
<span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">linestring</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;</span> <span class="identifier">linestring</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">variant</span><span class="special">&lt;</span><span class="identifier">polygon</span><span class="special">,</span> <span class="identifier">ring</span><span class="special">,</span> <span class="identifier">linestring</span><span class="special">&gt;</span> <span class="identifier">geometry</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="keyword">unsigned</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">&gt;</span> <span class="identifier">map</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">,</span> <span class="identifier">map</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">&gt;</span> <span class="identifier">value</span><span class="special">;</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Container</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">fill</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">i</span><span class="special">,</span> <span class="identifier">Container</span> <span class="special">&amp;</span> <span class="identifier">container</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">float</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">0</span> <span class="special">;</span> <span class="identifier">a</span> <span class="special">&lt;</span> <span class="number">6.28316f</span> <span class="special">;</span> <span class="identifier">a</span> <span class="special">+=</span> <span class="number">1.04720f</span> <span class="special">)</span>
    <span class="special">{</span>
        <span class="keyword">float</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">i</span> <span class="special">+</span> <span class="keyword">int</span><span class="special">(</span><span class="number">10</span><span class="special">*::</span><span class="identifier">cos</span><span class="special">(</span><span class="identifier">a</span><span class="special">))*</span><span class="number">0.1f</span><span class="special">;</span>
        <span class="keyword">float</span> <span class="identifier">y</span> <span class="special">=</span> <span class="identifier">i</span> <span class="special">+</span> <span class="keyword">int</span><span class="special">(</span><span class="number">10</span><span class="special">*::</span><span class="identifier">sin</span><span class="special">(</span><span class="identifier">a</span><span class="special">))*</span><span class="number">0.1f</span><span class="special">;</span>
        <span class="identifier">container</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">point</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">));</span>
    <span class="special">}</span>
<span class="special">}</span>

<span class="keyword">struct</span> <span class="identifier">print_visitor</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_visitor</span><span class="special">&lt;&gt;</span>
<span class="special">{</span>
    <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">polygon</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">polygon</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
    <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">ring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">ring</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
    <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">linestring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">linestring</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="special">}</span>
<span class="special">};</span>

<span class="keyword">struct</span> <span class="identifier">envelope_visitor</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_visitor</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;</span>
<span class="special">{</span>
    <span class="identifier">box</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">polygon</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">return_envelope</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">);</span> <span class="special">}</span>
    <span class="identifier">box</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">ring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">return_envelope</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">);</span> <span class="special">}</span>
    <span class="identifier">box</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">linestring</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">g</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">return_envelope</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">g</span><span class="special">);</span> <span class="special">}</span>
<span class="special">};</span>


<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
    <span class="comment">// geometries container</span>
    <span class="identifier">map</span> <span class="identifier">geometries</span><span class="special">;</span>

    <span class="comment">// create some geometries</span>
    <span class="keyword">for</span> <span class="special">(</span> <span class="keyword">unsigned</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span> <span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">10</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span>
    <span class="special">{</span>
        <span class="keyword">unsigned</span> <span class="identifier">c</span> <span class="special">=</span> <span class="identifier">rand</span><span class="special">()</span> <span class="special">%</span> <span class="number">3</span><span class="special">;</span>

        <span class="keyword">if</span> <span class="special">(</span> <span class="number">0</span> <span class="special">==</span> <span class="identifier">c</span> <span class="special">)</span>
        <span class="special">{</span>
            <span class="comment">// create polygon</span>
            <span class="identifier">polygon</span> <span class="identifier">p</span><span class="special">;</span>
            <span class="identifier">fill</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">outer</span><span class="special">());</span>
            <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">(</span><span class="identifier">p</span><span class="special">)));</span>
        <span class="special">}</span>
        <span class="keyword">else</span> <span class="keyword">if</span> <span class="special">(</span> <span class="number">1</span> <span class="special">==</span> <span class="identifier">c</span> <span class="special">)</span>
        <span class="special">{</span>
            <span class="comment">// create ring</span>
            <span class="identifier">ring</span> <span class="identifier">r</span><span class="special">;</span>
            <span class="identifier">fill</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">r</span><span class="special">);</span>
            <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">(</span><span class="identifier">r</span><span class="special">)));</span>
        <span class="special">}</span>
        <span class="keyword">else</span> <span class="keyword">if</span> <span class="special">(</span> <span class="number">2</span> <span class="special">==</span> <span class="identifier">c</span> <span class="special">)</span>
        <span class="special">{</span>
            <span class="comment">// create linestring</span>
            <span class="identifier">linestring</span> <span class="identifier">l</span><span class="special">;</span>
            <span class="identifier">fill</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">l</span><span class="special">);</span>
            <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">(</span><span class="identifier">l</span><span class="special">)));</span>
        <span class="special">}</span>
    <span class="special">}</span>

    <span class="comment">// display geometries</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"generated geometries:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">geometries</span><span class="special">)</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">print_visitor</span><span class="special">(),</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span><span class="special">);</span>

    <span class="comment">// create the rtree using default constructor</span>
    <span class="identifier">bgi</span><span class="special">::</span><span class="identifier">rtree</span><span class="special">&lt;</span> <span class="identifier">value</span><span class="special">,</span> <span class="identifier">bgi</span><span class="special">::</span><span class="identifier">quadratic</span><span class="special">&lt;</span><span class="number">16</span><span class="special">,</span> <span class="number">4</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">rtree</span><span class="special">;</span>

    <span class="comment">// fill the spatial index</span>
    <span class="keyword">for</span> <span class="special">(</span> <span class="identifier">map</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">geometries</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">it</span> <span class="special">)</span>
    <span class="special">{</span>
        <span class="comment">// calculate polygon bounding box</span>
        <span class="identifier">box</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">envelope_visitor</span><span class="special">(),</span> <span class="identifier">it</span><span class="special">-&gt;</span><span class="identifier">second</span><span class="special">);</span>
        <span class="comment">// insert new value</span>
        <span class="identifier">rtree</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">it</span><span class="special">));</span>
    <span class="special">}</span>

    <span class="comment">// find values intersecting some area defined by a box</span>
    <span class="identifier">box</span> <span class="identifier">query_box</span><span class="special">(</span><span class="identifier">point</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">),</span> <span class="identifier">point</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="number">5</span><span class="special">));</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">value</span><span class="special">&gt;</span> <span class="identifier">result_s</span><span class="special">;</span>
    <span class="identifier">rtree</span><span class="special">.</span><span class="identifier">query</span><span class="special">(</span><span class="identifier">bgi</span><span class="special">::</span><span class="identifier">intersects</span><span class="special">(</span><span class="identifier">query_box</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">result_s</span><span class="special">));</span>

    <span class="comment">// find 5 nearest values to a point</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">value</span><span class="special">&gt;</span> <span class="identifier">result_n</span><span class="special">;</span>
    <span class="identifier">rtree</span><span class="special">.</span><span class="identifier">query</span><span class="special">(</span><span class="identifier">bgi</span><span class="special">::</span><span class="identifier">nearest</span><span class="special">(</span><span class="identifier">point</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">),</span> <span class="number">5</span><span class="special">),</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">result_n</span><span class="special">));</span>

    <span class="comment">// note: in Boost.Geometry the WKT representation of a box is polygon</span>

    <span class="comment">// note: the values store the bounding boxes of geometries</span>
    <span class="comment">// the geometries aren't used for querying but are printed</span>

    <span class="comment">// display results</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"spatial query box:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">box</span><span class="special">&gt;(</span><span class="identifier">query_box</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"spatial query result:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">value</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">result_s</span><span class="special">)</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">print_visitor</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">second</span><span class="special">-&gt;</span><span class="identifier">second</span><span class="special">);</span>

    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"knn query point:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">wkt</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="identifier">point</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">))</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"knn query result:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">value</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">result_n</span><span class="special">)</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">apply_visitor</span><span class="special">(</span><span class="identifier">print_visitor</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">second</span><span class="special">-&gt;</span><span class="identifier">second</span><span class="special">);</span>

    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
        </p>
<h5>
<a name="geometry.spatial_indexes.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries.h0"></a>
          <span class="phrase"><a name="geometry.spatial_indexes.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries.expected_results"></a></span><a class="link" href="index_of_iterators_of_a_map_storing_variant_geometries.html#geometry.spatial_indexes.rtree_examples.index_of_iterators_of_a_map_storing_variant_geometries.expected_results">Expected
          results</a>
        </h5>
<pre class="programlisting"><span class="identifier">generated</span> <span class="identifier">geometries</span><span class="special">:</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">1</span> <span class="number">0</span><span class="special">,</span><span class="number">0.4</span> <span class="number">0.8</span><span class="special">,-</span><span class="number">0.5</span> <span class="number">0.8</span><span class="special">,-</span><span class="number">0.9</span> <span class="number">0</span><span class="special">,-</span><span class="number">0.4</span> <span class="special">-</span><span class="number">0.8</span><span class="special">,</span><span class="number">0.5</span> <span class="special">-</span><span class="number">0.8</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">2</span> <span class="number">1</span><span class="special">,</span><span class="number">1.4</span> <span class="number">1.8</span><span class="special">,</span><span class="number">0.5</span> <span class="number">1.8</span><span class="special">,</span><span class="number">0.1</span> <span class="number">1</span><span class="special">,</span><span class="number">0.6</span> <span class="number">0.2</span><span class="special">,</span><span class="number">1.5</span> <span class="number">0.2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">3</span> <span class="number">2</span><span class="special">,</span><span class="number">2.4</span> <span class="number">2.8</span><span class="special">,</span><span class="number">1.5</span> <span class="number">2.8</span><span class="special">,</span><span class="number">1.1</span> <span class="number">2</span><span class="special">,</span><span class="number">1.6</span> <span class="number">1.2</span><span class="special">,</span><span class="number">2.5</span> <span class="number">1.2</span><span class="special">,</span><span class="number">3</span> <span class="number">2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">4</span> <span class="number">3</span><span class="special">,</span><span class="number">3.4</span> <span class="number">3.8</span><span class="special">,</span><span class="number">2.5</span> <span class="number">3.8</span><span class="special">,</span><span class="number">2.1</span> <span class="number">3</span><span class="special">,</span><span class="number">2.6</span> <span class="number">2.2</span><span class="special">,</span><span class="number">3.5</span> <span class="number">2.2</span><span class="special">))</span>
<span class="identifier">LINESTRING</span><span class="special">(</span><span class="number">5</span> <span class="number">4</span><span class="special">,</span><span class="number">4.4</span> <span class="number">4.8</span><span class="special">,</span><span class="number">3.5</span> <span class="number">4.8</span><span class="special">,</span><span class="number">3.1</span> <span class="number">4</span><span class="special">,</span><span class="number">3.6</span> <span class="number">3.2</span><span class="special">,</span><span class="number">4.5</span> <span class="number">3.2</span><span class="special">)</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">6</span> <span class="number">5</span><span class="special">,</span><span class="number">5.4</span> <span class="number">5.8</span><span class="special">,</span><span class="number">4.5</span> <span class="number">5.8</span><span class="special">,</span><span class="number">4.1</span> <span class="number">5</span><span class="special">,</span><span class="number">4.6</span> <span class="number">4.2</span><span class="special">,</span><span class="number">5.5</span> <span class="number">4.2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">7</span> <span class="number">6</span><span class="special">,</span><span class="number">6.4</span> <span class="number">6.8</span><span class="special">,</span><span class="number">5.5</span> <span class="number">6.8</span><span class="special">,</span><span class="number">5.1</span> <span class="number">6</span><span class="special">,</span><span class="number">5.6</span> <span class="number">5.2</span><span class="special">,</span><span class="number">6.5</span> <span class="number">5.2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">8</span> <span class="number">7</span><span class="special">,</span><span class="number">7.4</span> <span class="number">7.8</span><span class="special">,</span><span class="number">6.5</span> <span class="number">7.8</span><span class="special">,</span><span class="number">6.1</span> <span class="number">7</span><span class="special">,</span><span class="number">6.6</span> <span class="number">6.2</span><span class="special">,</span><span class="number">7.5</span> <span class="number">6.2</span><span class="special">,</span><span class="number">8</span> <span class="number">7</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">9</span> <span class="number">8</span><span class="special">,</span><span class="number">8.4</span> <span class="number">8.8</span><span class="special">,</span><span class="number">7.5</span> <span class="number">8.8</span><span class="special">,</span><span class="number">7.1</span> <span class="number">8</span><span class="special">,</span><span class="number">7.6</span> <span class="number">7.2</span><span class="special">,</span><span class="number">8.5</span> <span class="number">7.2</span><span class="special">,</span><span class="number">9</span> <span class="number">8</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">10</span> <span class="number">9</span><span class="special">,</span><span class="number">9.4</span> <span class="number">9.8</span><span class="special">,</span><span class="number">8.5</span> <span class="number">9.8</span><span class="special">,</span><span class="number">8.1</span> <span class="number">9</span><span class="special">,</span><span class="number">8.6</span> <span class="number">8.2</span><span class="special">,</span><span class="number">9.5</span> <span class="number">8.2</span><span class="special">))</span>
<span class="identifier">spatial</span> <span class="identifier">query</span> <span class="identifier">box</span><span class="special">:</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">0</span> <span class="number">0</span><span class="special">,</span><span class="number">0</span> <span class="number">5</span><span class="special">,</span><span class="number">5</span> <span class="number">5</span><span class="special">,</span><span class="number">5</span> <span class="number">0</span><span class="special">,</span><span class="number">0</span> <span class="number">0</span><span class="special">))</span>
<span class="identifier">spatial</span> <span class="identifier">query</span> <span class="identifier">result</span><span class="special">:</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">1</span> <span class="number">0</span><span class="special">,</span><span class="number">0.4</span> <span class="number">0.8</span><span class="special">,-</span><span class="number">0.5</span> <span class="number">0.8</span><span class="special">,-</span><span class="number">0.9</span> <span class="number">0</span><span class="special">,-</span><span class="number">0.4</span> <span class="special">-</span><span class="number">0.8</span><span class="special">,</span><span class="number">0.5</span> <span class="special">-</span><span class="number">0.8</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">2</span> <span class="number">1</span><span class="special">,</span><span class="number">1.4</span> <span class="number">1.8</span><span class="special">,</span><span class="number">0.5</span> <span class="number">1.8</span><span class="special">,</span><span class="number">0.1</span> <span class="number">1</span><span class="special">,</span><span class="number">0.6</span> <span class="number">0.2</span><span class="special">,</span><span class="number">1.5</span> <span class="number">0.2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">3</span> <span class="number">2</span><span class="special">,</span><span class="number">2.4</span> <span class="number">2.8</span><span class="special">,</span><span class="number">1.5</span> <span class="number">2.8</span><span class="special">,</span><span class="number">1.1</span> <span class="number">2</span><span class="special">,</span><span class="number">1.6</span> <span class="number">1.2</span><span class="special">,</span><span class="number">2.5</span> <span class="number">1.2</span><span class="special">,</span><span class="number">3</span> <span class="number">2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">4</span> <span class="number">3</span><span class="special">,</span><span class="number">3.4</span> <span class="number">3.8</span><span class="special">,</span><span class="number">2.5</span> <span class="number">3.8</span><span class="special">,</span><span class="number">2.1</span> <span class="number">3</span><span class="special">,</span><span class="number">2.6</span> <span class="number">2.2</span><span class="special">,</span><span class="number">3.5</span> <span class="number">2.2</span><span class="special">))</span>
<span class="identifier">LINESTRING</span><span class="special">(</span><span class="number">5</span> <span class="number">4</span><span class="special">,</span><span class="number">4.4</span> <span class="number">4.8</span><span class="special">,</span><span class="number">3.5</span> <span class="number">4.8</span><span class="special">,</span><span class="number">3.1</span> <span class="number">4</span><span class="special">,</span><span class="number">3.6</span> <span class="number">3.2</span><span class="special">,</span><span class="number">4.5</span> <span class="number">3.2</span><span class="special">)</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">6</span> <span class="number">5</span><span class="special">,</span><span class="number">5.4</span> <span class="number">5.8</span><span class="special">,</span><span class="number">4.5</span> <span class="number">5.8</span><span class="special">,</span><span class="number">4.1</span> <span class="number">5</span><span class="special">,</span><span class="number">4.6</span> <span class="number">4.2</span><span class="special">,</span><span class="number">5.5</span> <span class="number">4.2</span><span class="special">))</span>
<span class="identifier">knn</span> <span class="identifier">query</span> <span class="identifier">point</span><span class="special">:</span>
<span class="identifier">POINT</span><span class="special">(</span><span class="number">0</span> <span class="number">0</span><span class="special">)</span>
<span class="identifier">knn</span> <span class="identifier">query</span> <span class="identifier">result</span><span class="special">:</span>
<span class="identifier">LINESTRING</span><span class="special">(</span><span class="number">5</span> <span class="number">4</span><span class="special">,</span><span class="number">4.4</span> <span class="number">4.8</span><span class="special">,</span><span class="number">3.5</span> <span class="number">4.8</span><span class="special">,</span><span class="number">3.1</span> <span class="number">4</span><span class="special">,</span><span class="number">3.6</span> <span class="number">3.2</span><span class="special">,</span><span class="number">4.5</span> <span class="number">3.2</span><span class="special">)</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">4</span> <span class="number">3</span><span class="special">,</span><span class="number">3.4</span> <span class="number">3.8</span><span class="special">,</span><span class="number">2.5</span> <span class="number">3.8</span><span class="special">,</span><span class="number">2.1</span> <span class="number">3</span><span class="special">,</span><span class="number">2.6</span> <span class="number">2.2</span><span class="special">,</span><span class="number">3.5</span> <span class="number">2.2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">3</span> <span class="number">2</span><span class="special">,</span><span class="number">2.4</span> <span class="number">2.8</span><span class="special">,</span><span class="number">1.5</span> <span class="number">2.8</span><span class="special">,</span><span class="number">1.1</span> <span class="number">2</span><span class="special">,</span><span class="number">1.6</span> <span class="number">1.2</span><span class="special">,</span><span class="number">2.5</span> <span class="number">1.2</span><span class="special">,</span><span class="number">3</span> <span class="number">2</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">1</span> <span class="number">0</span><span class="special">,</span><span class="number">0.4</span> <span class="number">0.8</span><span class="special">,-</span><span class="number">0.5</span> <span class="number">0.8</span><span class="special">,-</span><span class="number">0.9</span> <span class="number">0</span><span class="special">,-</span><span class="number">0.4</span> <span class="special">-</span><span class="number">0.8</span><span class="special">,</span><span class="number">0.5</span> <span class="special">-</span><span class="number">0.8</span><span class="special">))</span>
<span class="identifier">POLYGON</span><span class="special">((</span><span class="number">2</span> <span class="number">1</span><span class="special">,</span><span class="number">1.4</span> <span class="number">1.8</span><span class="special">,</span><span class="number">0.5</span> <span class="number">1.8</span><span class="special">,</span><span class="number">0.1</span> <span class="number">1</span><span class="special">,</span><span class="number">0.6</span> <span class="number">0.2</span><span class="special">,</span><span class="number">1.5</span> <span class="number">0.2</span><span class="special">))</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2021 Barend Gehrels,
      Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="index_of_shared_pointers_to_polygons.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rtree_examples.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="specializing_index__indexable_function_object___storing_shared_pointers_in_the_rtree.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
